<template>
	<view>
		<navbox title="系统消息"></navbox>
		<view class="conn">
			<u-cell-group v-if="show">
				<u-cell :value="item.createTime" v-for="item in list" :key="item.id" :label="item.content"
					@click="kan(item)">
					<u-icon :color="item.status==='1'?'#e82315':'#bab3a6'" slot="icon" size="25" name="chat"></u-icon>
				</u-cell>
			</u-cell-group>
			<view>
				<u-modal :show="showmodal" :content='item.content' @confirm="confirm()"></u-modal>
			</view>
			<u-empty mode="search" icon="http://cdn.uviewui.com/uview/empty/search.png" v-if="!show">
			</u-empty>
		</view>
	</view>
</template>
<script>
	import navbox from '../components/navbox/navbox.vue'
	export default {
		data() {
			return {
				showmodal: false,
				show: true,
				user: uni.getStorageSync("user"),
				list: [],
				item: {}
			}
		},
		onLoad() {
			this.getlist()
		},
		methods: {
			async confirm() {
				if (this.item.status === "1") {
					const res = await this.$myRuquest({
						url: '/wexinLogin/settingNews/read?id=' + this.item.id
					})
					this.getlist()
				}
				this.showmodal = false
			},
			kan(item) {
				this.item = item
				this.showmodal = true
			},
			async getlist() {
				if (this.user === null || this.user === '') {
					this.show = false
					return uni.showToast({
						title: "token过期，重新登录",
						icon: 'none'
					})
				}
				const res = await this.$myRuquest({
					url: '/wexinLogin/settingNews/newsList?id=' + this.user.id
				})
				this.list = res.data.data
			}
		},
		components: {
			"navbox": navbox
		},
	}
</script>
<style>
	.conn {
		margin-top: 180rpx;
	}

	.box {
		width: 100px;
		height: 100px;
		background-color: #909193;
		border-radius: 15px;
	}
</style>
